@import "app/styles/mixins"
@import "app/styles/bootstrap/variables"

$mapHeight: 1536
$mapWidth: 2350
$levelDotWidth: 2%
$levelDotHeight: $levelDotWidth * $mapWidth / $mapHeight
$levelDotZ: $levelDotHeight * 0.25
$levelDotHoverZ: $levelDotZ * 1.5
$levelDotShadowWidth: 0.8 * $levelDotWidth
$levelDotShadowHeight: 0.8 * $levelDotHeight
$levelClickRadius: 20px
$gameControlSize: 80px
$gameControlMargin: 30px

+keyframes(levelStartedPulse)
  from
    @include box-shadow(0px 0px 4px #333)
    margin-bottom: -$levelDotHeight / 3 + $levelDotZ
  50%
    @include box-shadow(0px 0px 22px skyblue)
    margin-bottom: -$levelDotHeight / 3 + ($levelDotHoverZ + $levelDotZ) / 2
  to
    @include box-shadow(0px 0px 4px #333)
    margin-bottom: -$levelDotHeight / 3 + $levelDotZ

#campaign-view
  top: 0
  right: 0
  bottom: 0
  left: 0
  position: absolute

  .gradient
    position: absolute
    z-index: 0

    &.horizontal-gradient
      left: 0
      right: 0
      height: 3%

    &.vertical-gradient
      top: 0
      bottom: 0
      width: 3%

    &.top-gradient
      top: 0

    &.right-gradient
      right: 0

    &.bottom-gradient
      bottom: 0

    &.left-gradient
      left: 0

  .map
    position: relative
    
    #brain-pop-done-banner-wrapper
      position: absolute
      top: 20%
      width: 100%
      z-index: 3
      #brain-pop-done-banner
        background: url("/images/pages/base/modal_background.png")
        background-size: 100% 100%
        width: 400px
        margin: 0 auto
        padding: 20px 40px
        text-align: center
        img
          margin-bottom: 10px

    // Minecraft modal
    #cube-level-container
      position: absolute
      left: 30%
      top: 15%
      background-color: rgb(80, 130, 200)

      #spinning-cube
        position: absolute
        top: -32px
        width: 32px
        height: 32px
        transform: translateX(-50%) scaleY(1.33)
        left: 50%
        perspective: 800px
        perspective-origin: 50% 100px
        filter: drop-shadow(0px 0px 4px purple) drop-shadow(0px 0px 4px purple) drop-shadow(0px 0px 4px purple)

        .cube
          position: relative
          width: 32px
          transform-style: preserve-3d
          animation: spin 5s infinite linear

          +keyframes(spin)
            from
              -moz-transform: rotateX(180deg) rotateY(0deg)
              -o-transform: rotateX(180deg) rotateY(0deg)
              -webkit-transform: rotateX(180deg) rotateY(0deg)
              transform: rotateX(180deg) rotateY(0deg)
            to
              -moz-transform: rotateX(540deg) rotateY(360deg)
              -o-transform: rotateX(540deg) rotateY(360deg)
              -webkit-transform: rotateX(540deg) rotateY(360deg)
              transform: rotateX(540deg) rotateY(360deg)

          div
            width: 32px
            height: 32px
            position: absolute
            background-size: 100% 100%
            color: white

          .front, .back, .left, .right
            background-image: url('/images/minecraft/grass_side.png')
          .top
            background-image: url('/images/minecraft/grass_top.png')
          .bottom
            background-image: url('/images/minecraft/dirt.png')
          .front
            -moz-transform: translateY(-16px) rotateY(0deg) translateZ(-16px) rotateX(180deg)
            -o-transform: translateY(-16px) rotateY(0deg) translateZ(-16px) rotateX(180deg)
            -webkit-transform: translateY(-16px) rotateY(0deg) translateZ(-16px) rotateX(180deg)
            transform: translateY(-16px) rotateY(0deg) translateZ(-16px) rotateX(180deg)
          .back
            -moz-transform: translateY(-16px) rotateX(180deg) translateZ(-16px)
            -o-transform: translateY(-16px) rotateX(180deg) translateZ(-16px)
            -webkit-transform: translateY(-16px) rotateX(180deg) translateZ(-16px)
            transform: translateY(-16px) rotateX(180deg) translateZ(-16px)
          .left
            -moz-transform: translateY(-16px) rotateY(-89.9deg) translateZ(-16px) rotateX(180deg)
            -o-transform: translateY(-16px) rotateY(-89.9deg) translateZ(-16px) rotateX(180deg)
            -webkit-transform: translateY(-16px) rotateY(-89.9deg) translateZ(-16px) rotateX(180deg)
            transform: translateY(-16px) rotateY(-89.9deg) translateZ(-16px) rotateX(180deg)
          .right
            -moz-transform: translateY(-16px) rotateY(89.9deg) translateZ(-16px) rotateX(180deg)
            -o-transform: translateY(-16px) rotateY(89.9deg) translateZ(-16px) rotateX(180deg)
            -webkit-transform: translateY(-16px) rotateY(89.9deg) translateZ(-16px) rotateX(180deg)
            transform: translateY(-16px) rotateY(89.9deg) translateZ(-16px) rotateX(180deg)
          .top
            -moz-transform: translateY(-16px) rotateX(89.9deg) translateZ(-16px)
            -o-transform: translateY(-16px) rotateX(89.9deg) translateZ(-16px)
            -webkit-transform: translateY(-16px) rotateX(89.9deg) translateZ(-16px)
            transform: translateY(-16px) rotateX(89.9deg) translateZ(-16px)
          .bottom
            -moz-transform: translateY(-16px) rotateX(-89.9deg) translateZ(-16px)
            -o-transform: translateY(-16px) rotateX(-89.9deg) translateZ(-16px)
            -webkit-transform: translateY(-16px) rotateX(-89.9deg) translateZ(-16px)
            transform: translateY(-16px) rotateX(-89.9deg) translateZ(-16px)


    .map-background
      width: 100%
      height: 100%
      background-size: 100%
      @include user-select(none)

    .level, .level-shadow
      position: absolute
      border-radius: 50%
      -webkit-transform: scaleY(0.75)
      transform: scaleY(0.75)

    .level
      z-index: 2
      width: $levelDotWidth
      height: $levelDotHeight
      margin-left: -0.5 * $levelDotWidth
      margin-bottom: -$levelDotHeight / 3 + $levelDotZ
      border: 2px groove white
      @include transition(margin-bottom 0.5s ease)
      cursor: pointer

      .treasure-chest
        position: absolute
        left: 50%
        width: 150%
        transform: translateX(-50%) translateX(50%) translateY(-130%) scaleY(1.33) scale(0.75)
        cursor: pointer
        z-index: -1
        filter: drop-shadow(0px 0px 4px gold)

      &.disabled, &.locked
        //background-image: url(/images/pages/game-menu/lock.png)
        //background-size: 75%
        //background-repeat: no-repeat
        //background-position: 50% 50%
        opacity: 0.7
        width: $levelDotWidth * 0.67
        height: $levelDotHeight * 0.67
        margin-left: -0.5 * 0.67 * $levelDotWidth
        margin-bottom: -$levelDotHeight / 3 * 0.67 + $levelDotZ / 2

        .treasure-chest
          transform: translateX(-50%) translateY(-200%) scaleY(1.33) scale(0.95)


      &.started, &.next
        border: 3px solid lightgreen
        @include box-shadow(0px 0px 35px skyblue)

        // Would be cool, but kills performance, since we have to re-render all the time.
        //&:not(:hover)
        //  -webkit-animation-name: levelStartedPulse
        //  -webkit-animation-duration: 3s
        //  -webkit-animation-iteration-count: infinite

      &.complete
        border: 3px solid gold
        @include box-shadow(0px 0px 35px skyblue)

      .level-difficulty-banner-text
        position: absolute
        bottom: 160%
        pointer-events: none
        color: rgb(246, 208, 2)
        text-shadow: 0px 1px 0px black
        font-size: 1.8vw
        z-index: 1
        width: 100%
        text-align: center

      img.banner
        position: absolute
        bottom: 38%
        width: 170%
        left: -35%

      img.star
        width: 100%
        bottom: 4%
        position: absolute
        pointer-events: none

      .level-acronym, .level-kind
        position: absolute
        pointer-events: none
        left: 0
        top: 0
        right: 0
        bottom: 0
        color: black
        text-align: center
        font-size: 0.8vw
        text-shadow: 0px 1px 0px white

      .level-kind
        bottom: auto
        top: 100%
        color: white
        text-shadow: 0px 1px 0px black, 0px -1px 0px black, -1px 0px 0px black, 1px 0px 0px black

        &.demo
          color: rgb(128, 255, 128)
        &.usage
          color: rgb(128, 128, 255)
        &.mastery
          color: rgb(255, 128, 128)
        &.practice
          color: rgb(128, 128, 255)
        &.advanced
          color: rgb(128, 255, 255)
        &.challenge
          color: rgb(255, 255, 128)

      img.hero-portrait, img.item-portrait
        width: 120%
        height: auto
        bottom: 75%
        left: 75%
        margin-left: 0
        margin-bottom: 0

    img.premium-hero-banner
      position: absolute
      height: 250%
      transform: translate(-50%, -100%) translateX(-20%) translateY(-10%) scaleY(1.33)
      filter: drop-shadow(0px 0px 10px black)
      z-index: 3

    img.pet-banner
      position: absolute
      height: 250%
      transform: translate(-50%, -80%) translateX(-20%) translateY(-10%) scaleY(1.33) scale(0.625)
      filter: drop-shadow(0px 0px 10px black)
      z-index: 3

    img.hero-portrait, img.item-portrait
      position: absolute
      border: 1px solid black
      border-radius: 50%
      background: white
      width: $levelDotWidth * 1.5
      height: $levelDotHeight * 1.5 / 1.75
      margin-left: -0.5 * $levelDotWidth * 1.5
      margin-bottom: -$levelDotHeight / 3 * 1.5 / 1.75

      &.hero-portrait-on-banner, &.item-portrait-on-banner
        bottom: 170%
        left: 0%
        width: 100%

      &.item-portrait-on-banner
        background: transparent
        border: 0
        border-radius: 0

    .level-shadow
      z-index: 1
      width: $levelDotShadowWidth
      height: $levelDotShadowHeight
      margin-left: -0.5 * $levelDotShadowWidth
      margin-bottom: -$levelDotShadowHeight / 3
      background-color: black
      @include box-shadow(0px 0px 10px black)
      @include opacity(0.75)

      &.locked
        @include opacity(0.5)
        width: $levelDotShadowWidth * 0.67
        height: $levelDotShadowHeight * 0.67
        margin-left: -0.5 * 0.67 * $levelDotShadowWidth
        margin-bottom: -$levelDotShadowHeight / 3 * 0.67

    .level:hover
      // TODO: This rotate stops Firefox from flickering, but also disables the scaleY(0.75)
      // TODO: The dot looks like it's jumping.
      // TODO: -moz-transform: scaleY(0.75) didn't do anything
      // TODO: Does not break Chrome's oval.
      -moz-transform: rotate(0)
      margin-bottom: -$levelDotHeight / 3 + $levelDotHoverZ
      @include box-shadow(0px 0px 35px skyblue)

    .level
      a
        display: block
        padding: $levelClickRadius
        margin-left: -0.5 * $levelClickRadius
        margin-top: -0.5 * $levelClickRadius
        border-radius: $levelClickRadius

    .tooltip
      z-index: 3
      pointer-events: none

      .tooltip-arrow
        display: none

    .level-info-container
      display: none
      position: absolute
      z-index: 3
      width: 362px
      //min-height: 179px
      padding: 17px 20px 20px 20px
      border: 0
      background: transparent url(/images/pages/play/level-info-background.png) no-repeat center center
      background-size: 100% 100%

      .level-info

        h3
          color: rgb(232, 217, 87)
          text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0
          padding: 0 2px
          margin: 0 0 10px 31px
          white-space: nowrap
          overflow: hidden
          text-overflow: ellipsis

        .level-description
          color: black

          img
            display: block
            margin: 0px auto
            max-width: 100%

        kbd
          margin: 0 2px 2px 0
          display: inline-block
          font-size: 12px

        .level-status
          background: transparent url(/images/pages/play/level-info-status-spritesheet.png) no-repeat 0 0
          width: 60px
          height: 60px
          position: absolute
          left: -15px
          top: -15px

        &.complete .level-status
          background-position: -60px 0

        &.premium .level-status
          background-position: -120px 0

        &.complete.premium .level-status
          background-position: -180px 0

        .start-level
          min-width: 200px
          display: block
          margin: 10px auto 0 auto
          position: relative

          .badge
            position: absolute
            top: auto
            left: auto
            right: -25px
            bottom: -25px
            font-size: 20px
            color: black
            border: 1px solid black
            background-color: rgb(232, 217, 87)
            border-radius: 50%
            opacity: 1
            padding: 3px 9px

        &.shows-leaderboard
          .start-level, .view-solutions
            min-width: calc(50% - 5px)
            display: inline-block
            width: calc(50% - 5px)

          .start-level
            margin: 10px 0 0 5px

          .view-solutions
            margin: 10px 5px 0 0

        .course-version
          text-align: center

    .campaign-switch
      color: purple
      position: absolute
      z-index: 1
      font-size: 2vw
      text-shadow: 0 0 0.3vw white, 0 0 0.3vw white

      &:hover
        text-decoration: none

  .next-level-line
    height: 8px
    position: absolute

    .line
      width: calc(100% - 24px)
      float: left
      margin-top: 2px
      margin-bottom: 2px
      height: 4px
      background: repeating-linear-gradient(-45deg, #AF9F7D, #DFC89C 5px, #F1EAC0 5px, #AF9F7D 10px)
      box-shadow: 0px 0px 4px black

    .point
      width: 24px
      height: 24px
      float: right
      margin-top: -8px
      border-top: 12px solid transparent
      border-bottom: 12px solid transparent
      border-left: 24px solid lighten(#F1EAC0, 10%)

  .game-controls
    position: absolute
    right: 1%
    bottom: 1%
    z-index: 2

    .btn
      &:not(:first-child)
        margin-left: $gameControlMargin
        @media only screen and (max-height: 650px)
          margin-left: 0

      width: $gameControlSize
      height: $gameControlSize

      @media only screen and (max-height: 650px)
        @include scale(0.67)

      background: url(/images/pages/play/menu_icons.png) no-repeat

      position: relative
      img
        position: absolute
        left: 0
        top: 0
        width: 100%
        height: 100%

      background-size: cover
      @include transition(0.5s ease)
      @include box-shadow(2px 2px 4px black)
      border: 0
      border-radius: 12px
      // IE9 shows a blank white button with this MS gradient filter in place
      filter: none

      &:hover
        @include box-shadow(0 0 12px #bbf)

      &:active, &.highlighted
        @include box-shadow(0 0 20px white)

      &.items
        background-position: (-1 * $gameControlSize) 0px
      &.heroes
        background-position: (-2 * $gameControlSize) 0px
      &.achievements
        background-position: (-3 * $gameControlSize) 0px
      &.account
        background-position: (-5 * $gameControlSize) 0px
      &.settings
        background-position: (-5 * $gameControlSize) 0px
      &.gems
        background-position: (-6 * $gameControlSize) 0px
      &.poll
        background-position: (-4 * $gameControlSize) 0px
      &.premium-menu-icon
        background: url(/images/pages/play/premium-menu-icon.png) no-repeat
        background-position: 50% 50%
        background-size: 100%
        transform: scale(1.31) translateY(-5px) translateX(-6px)
        @media only screen and (max-height: 650px)
          transform: scale(0.67) scale(1.31) translateY(-5px) translateX(-6px)
        box-shadow: initial
        filter: drop-shadow(2px 2px 4px black)
        outline: none
        &:hover
          filter: drop-shadow(0 0 2px #bbf)


    .tooltip
      font-size: 24px

      .tooltip-arrow
        display: none

  .user-status
    position: absolute
    bottom: 16px
    left: 8px
    text-align: center
    font-size: 24px
    color: white
    text-shadow: 0px 2px 1px black, 0px -2px 1px black, -2px 0px 1px black, 2px 0px 1px black
    height: 32px
    line-height: 32px

    .user-status-line
      position: relative

      button.btn.btn-illustrated
        margin-left: 10px
        min-width: 90px
        height: 32px
        color: white

      .gem, .player-hero-icon
        position: absolute
        top: 1px

      #gems-count
        margin-left: 40px

      .player-level
        margin-left: 5px

      .player-name
        margin-left: 45px

      a
        color: white

      $spriteSheetSize: 30px

      .player-hero-icon
        background: transparent url(/images/pages/play/play-spritesheet.png)
        background-size: cover
        background-position: (-2 * $spriteSheetSize) 0
        display: inline-block
        width: 30px
        height: 30px
        margin: 0px 2px

      .level-indicator
        margin-left: 15px
        color: white
        display: inline-block
        margin: 0 2px

      .player-hero-icon
        margin-left: 10px
        background-position: (-4 * $spriteSheetSize) 0

        &.knight
          background-position: (-5 * $spriteSheetSize) 0
        &.librarian
          background-position: (-6 * $spriteSheetSize) 0
        &.ninja
          background-position: (-7 * $spriteSheetSize) 0
        &.potion-master
          background-position: (-8 * $spriteSheetSize) 0
        &.samurai
          background-position: (-9 * $spriteSheetSize) 0
        &.trapper
          background-position: (-10 * $spriteSheetSize) 0
        &.forest-archer
          background-position: (-11 * $spriteSheetSize) 0
        &.sorcerer
          background-position: (-12 * $spriteSheetSize) 0

  .campaign-control-button
    position: absolute
    right: 1%
    top: 1%
    padding: 3px 8px
    @include opacity(0.75)

    &:hover
      @include opacity(1.0)

    .glyphicon
      font-size: 32px

  #volume-button
    .glyphicon
      display: none

    &.vol-up .glyphicon.glyphicon-volume-up
      display: inline-block

    &.vol-off .glyphicon.glyphicon-volume-off
      display: inline-block
      @include opacity(0.50)
      &:hover
        @include opacity(0.75)

    &.vol-down .glyphicon.glyphicon-volume-down
      display: inline-block

  #back-button, #clear-storage-button
    position: absolute
    right: 70px
    right: -webkit-calc(1% + 55px)
    right: calc(1% + 55px)

  #campaign-status
    position: absolute
    left: 0
    top: 0
    width: 100%
    margin: 0
    text-align: center
    color: rgb(232, 217, 87)
    font-size: 28px
    text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0
    z-index: 30
    pointer-events: none

    .campaign-status-background
      background: transparent url(/images/pages/play/campaign-banner.png) no-repeat center center
      border-radius: 10px
      padding-top: 30px
      display: inline-block
      min-width: 250px
      height: 106px

      .campaign-name
        line-height: 26px

      .levels-completed
        font-size: 22px

  .particle-man
    z-index: 2

  .portal
    position: relative
    width: 100%
    height: 100%
    background: transparent url(/images/pages/play/portal-background.png)
    display: flex
    align-items: center
    justify-content: center
    overflow: hidden

    .portals
      $campaignWidth: 317px
      $campaignHeight: 634px
      $campaignHoverScale: 1.2
      height: $campaignHeight * $campaignHoverScale
      flex-wrap: nowrap
      display: flex
      overflow: hidden

      .campaign
        width: $campaignWidth
        height: $campaignHeight
        margin-top: $campaignHeight * ($campaignHoverScale - 1) / 2
        background: transparent url(/images/pages/play/portal-campaigns.png) no-repeat 0 0
        display: inline-block
        flex-shrink: 0
        position: relative
        cursor: pointer
        // http://easings.net/#easeOutBack plus tweaked a bit: http://cubic-bezier.com/#.11,.67,.08,1.42
        @include transition(0.25s cubic-bezier(0.11, 0.67, 0.8, 1.42))

        &:hover
          @include scale($campaignHoverScale)

        &.silhouette
          @include filter(contrast(50%) brightness(65%))
          pointer-events: none

        &.locked
          @include filter(contrast(80%) brightness(80%))
          pointer-events: none

        &.forest
          background-position: (-1 * $campaignWidth) 0
        &.desert
          background-position: (-2 * $campaignWidth) 0
        &.mountain
          background-position: (-3 * $campaignWidth) 0
        &.glacier
          background-position: (-4 * $campaignWidth) 0
        &.volcano
          background-position: (-5 * $campaignWidth) 0

        .campaign-label
          position: absolute
          top: 45%
          width: 100%
          text-align: center

          .campaign-name, .levels-completed, .campaign-locked
            margin: 0
            color: white
            text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0

          .campaign-locked
            margin: 32px 0

          .campaign-description
            margin: 0px 40px
            background: transparent url(/images/level/popover_border_background.png) no-repeat
            background-size: 100% 100%
            padding: 12px
            color: black

          .levels-completed
            font-size: 22px

          .play-button
            margin: 15px 0
            min-width: 100px

      .beta-container
        $betaImagesWidth: 1902px
        width: $campaignWidth
        height: $campaignHeight
        display: inline-block
        flex-shrink: 0
        position: relative

        .beta-campaign
          width: $campaignWidth
          height: $campaignHeight / 2
          display: inline-block
          flex-shrink: 0
          position: relative
          cursor: pointer
          // http://easings.net/#easeOutBack plus tweaked a bit: http://cubic-bezier.com/#.11,.67,.08,1.42
          @include transition(0.25s cubic-bezier(0.11, 0.67, 0.8, 1.42))

          &:hover
            @include scale($campaignHoverScale)

          &.silhouette
            @include filter(contrast(50%) brightness(65%))
            pointer-events: none

          &.locked
            @include filter(contrast(80%) brightness(80%))
            pointer-events: none

          .campaign-label
            position: absolute
            top: 40%
            width: 100%
            text-align: center

            .campaign-name, .levels-completed, .campaign-locked
              margin: 0
              color: white
              text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0

            .campaign-locked
              margin: 32px 0

            .campaign-description
              margin: 0px 40px
              background: transparent url(/images/level/popover_border_background.png) no-repeat
              background-size: 100% 100%
              padding: 12px
              color: black
              font-size: 12px

            .levels-completed
              font-size: 22px

            .play-button
              margin: 10px 0
              min-width: 100px
              color: white

          .background-container
            position: absolute
            left: $campaignWidth / 4
            width: $campaignWidth / 2
            height: $campaignHeight / 2
            background: transparent url(/images/pages/play/portal-beta-campaigns.png) no-repeat 0 0
            background-size: $betaImagesWidth / 2

            &.campaign-web-dev-1
              background-position: -151px 0px
            &.campaign-game-dev-1
              background-position: -454px 0px
            &.campaign-web-dev-2
              background-position: -291px 0px
            &.campaign-game-dev-2
              background-position: -628px 0px


  .small-nav-logo, .picoctf-powered-by
    position: absolute
    top: 1%
    left: 1%
    height: 60px
    z-index: 1

  .picoctf-logo .small-nav-logo
    height: 90px

  .under-logo
    position: absolute
    top: calc(1% + 55px)
    left: calc(1% + 20px)
    z-index: 1

  .picoctf-powered-by
    color: rgb(227, 173, 53)
    top: calc(1% + 90px)
    margin: 10px 10px 10px 15px

    img
      height: 30px

  .code-ninjas-logo
    top: calc(1% + 5px)
    left: calc(1% + 200px)
    
  .codeplay-logo
    top: calc(1% + 5px)
    left: calc(1% + 5px)
    height: 100px

  .ad-container
    width: 100%
    height: 90px
    text-align: center

  .gameplay-container
    position: absolute
    height: 100%
    width: 100%
    
  #codeplay-ad
    position: absolute
    right: 10px
    top: 60px
    height: calc(100% - 160px)
    z-index: 2

body.ipad #campaign-view
  // iPad only supports up to Kithgard Gates for now.
  .campaign-switch
    display: none

body[lang='ru'] .portals h2
  font-size: 26px
